package imper.main.listener;

import imper.engine.entity.Country;
import imper.engine.entity.Industry;
import imper.engine.util.ParameterManager;
import imper.engine.util.ProductionUtil;
import imper.graphic.ButtonListener;
import imper.graphic.event.ClickEvent;

public class RemoveIndustryListener implements ButtonListener
{
	protected Industry _industry;

	public RemoveIndustryListener(Industry pIndustry)
	{
		this._industry = pIndustry;
	}

	@Override
	public void click(ClickEvent pEvent)
	{
		Country country = ParameterManager.getInstance().getCountry();
		_industry.setProduct(_industry.getProduct() - 1);
		if (_industry.getProduct() >= 0)
		{
			ProductionUtil.calculateIndustry(country);
		} 
		else
		{
			_industry.setProduct(0);
		}
	}

}
